package String类编程题;

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Date;
import java.util.Scanner;

public class Question3 {
    public static void main(String[] args) {
        System.out.println("欢迎来到实时论坛交流区");
        System.out.println("===================================================");
        ArrayList<String> comments = new ArrayList<>();
        Scanner in = new Scanner(System.in);
        String[] keyWords = {"特朗普","普京"};
        do {
            System.out.println("====================================================");
            System.out.println("历史回帖记录: ");
            System.out.println("====================================================");
            for (String comment : comments) {
                System.out.println(comment);
            }
            System.out.println("请输入你的回帖内容:");
            String contents = in.nextLine();
            for (int i = 0; i < keyWords.length; i++) {
                contents=contents.replace(keyWords[i],"*".repeat(keyWords[i].length()));
            }
            comments.add(contents);
            System.out.println("退出聊天区?[Y/N]");
        } while (!in.nextLine().equalsIgnoreCase("y"));
    }
}
